home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 98 / Skunkware 98.iso / osr5 / sco / scripts / lchild < prev    next >
Encoding:
AWK Script  |  1997-08-26  |  868 b   |  30 lines

  1. #!/usr/local/bin/gawk -f
  2. # @(#) lchild.gawk 1.1 97/04/12
  3. # 91/02/27 john h. dubois iii (john@armory.com)
  4. # 92/02/16 added help
  5. # 92/05/01 put ps invokation inside awk prog
  6. # 96/06/18 3.2v5 port
  7. BEGIN {
  8.     Name = "lchild"
  9.     if (ARGC > 1) {
  10.     printf \
  11. "%s: list processes associated with the current tty that have children,\n"\
  12. "with the exception of this program.\n"
  13.     exit(0)
  14.     }
  15.     getline pid < "/dev/pid"
  16.     Cmd = "echo $$; exec ps -f < /dev/null"
  17.     Cmd | getline pspid
  18.     Cmd | getline
  19.     print $0    # print ps header
  20.     while ((Cmd | getline) == 1)
  21.     if (($2 != pid) && ($2 != pspid)) {     # ignore script processes
  22.         ppids[$3]     # generate set of all parent processes
  23.         p[$2] = $0    # save ps lines
  24.     }
  25.     close(Cmd)
  26.     for (pid in p)    # for each process
  27.     if (pid in ppids)     # if it was listed as a parent process
  28.         print p[pid]    # print its ps line
  29. }
  30.